/*
 * @Author: wangjing wangjin122@qq.com
 * @Date: 2024-02-21 09:06:23
 * @LastEditors: wangjing wangjin122@qq.com
 * @LastEditTime: 2024-02-21 10:13:50
 * @FilePath: \code-rain\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// const promise: Promise<string> = new Promise((r) => r("返回结果"))
// promise.then((res: string) => {
//   console.log(res)
// })
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
canvas.width = screen.width;
canvas.height = screen.height;
var str = '0123456789'.split('');
var arr = Array(Math.ceil(canvas.width / 10)).fill(0);
var rain = function () {
    ctx.fillStyle = 'rgba(0,0,0,0.05)';
    ctx.fillRect(0, 0, canvas.width, canvas.height);
    ctx.fillStyle = '#0f0';
    arr.forEach(function (item, index) {
        ctx.fillText(str[Math.floor(Math.random() * str.length)], index * 10, item + 10);
        arr[index] = item > canvas.height || item > Math.random() * 15000 ? 0 : item + 10;
    });
};
var timmer = setInterval(rain, 40);
canvas.onclick = function () {
    clearInterval(timmer);
};
canvas.ondblclick = function () {
    timmer = setInterval(rain, 40);
};
